
/**
 * @Author: 陈瑞鹏
 * @Date:   2023-01-06 16:36:52
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2023-01-07 15:46:56
 */
import gameCtr from "../gameCtr";

export default class victoryEntity {
  public id: number;
  public target: number; //胜利次数
  public desc: string;
  public rewardArr: any[]; //宝箱奖励
  public isRecive: false; //是否已领取
  public initTp(value) {
    this.id = value.id;
    this.target = value.target;
    this.desc = value.desc;
    this.rewardArr = JSON.parse(value.rewardArr);
  }

  /**
   * 按钮显示
   */
  public get btnStr() {
    let obj = {
      str: this.target + "胜",
      isCan: false,
    }

    if (this.isComplete()) {
      if (this.isRecive) {
        obj = {
          str: "已领取",
          isCan: false,
        }
      } else {
        obj = {
          str: "领取",
          isCan: true,
        }
      }
    }

    return obj;
  }
  /**
   * 是否完成
   */
  public isComplete() {
    return gameCtr.ins.victoryNum >= this.target;
  }
}